#!/bin/bash
#创建mysql表结构,数据库需要手动创建
dbname=$1
tablename=$2
type=$3
if [[ -z $dbname ]]
then
echo "empty dbname arg 1"
exit
fi
if [[ -z $tablename ]]
then
echo "empty tablename arg 2"
exit
fi
if [[ -z $type ]]
then
echo "empty dbtype arg 3,[myisam|innodb]"
exit
fi
sql='CREATE TABLE `'$tablename'` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(100) DEFAULT NULL,
  `area` varchar(100) DEFAULT NULL,
  `idlist` varchar(100) DEFAULT NULL,
  `memo` mediumtext,
  `time` datetime DEFAULT NULL,
  `staffid` int(11) DEFAULT NULL,
  `staffname` varchar(50) DEFAULT NULL,
  `flag` int(11) DEFAULT NULL,
  `sflag` varchar(1) DEFAULT NULL,
  `nid` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE='$type' DEFAULT CHARSET=utf8;'
echo $sql
mysql $dbname -e "$sql"